﻿using System;
using System.Collections.Generic;
using System.Linq;
using System.Text;
using Spinning.Spinning.Entity;
using Spinning.Spinning.Unitity;
using Microsoft.Xna.Framework;
using Spinning.Spinning.Scenes.ProcessScene.TabLayouts;
using Spinning.Spinning.Scenes.ProcessScene.Items;
using Spinning.Spinning.Interface;

namespace Spinning.Spinning.Scenes.ProcessScene.Store
{
    class SubStoreScene : TabLayoutScene, ISaveLoad
    {
        StoreSpinningScene _spinningStore;
        StoreItemsScene _itemStore;
        public override void OnLoad()
        {
            base.OnLoad();
            Size = new Microsoft.Xna.Framework.Vector2(426, 575);

            Tab top = new Tab(this);
            top.textureName = "item_store/tops";
            top.OnLoad();
            Tab items = new Tab(this);
            items.textureName = "item_store/items";
            items.OnLoad();

            _spinningStore = new StoreSpinningScene();
            _spinningStore.Color = Color.Transparent;
            _spinningStore.ZIndex = Constants.ui;
            _spinningStore.Position = new Vector2(0, 48);
            _spinningStore.OnLoad();
            this.Attach(_spinningStore);
            top.ContainScene = _spinningStore;

            _itemStore = new StoreItemsScene();
            _itemStore.Color = Color.Transparent;
            _itemStore.ZIndex = Constants.ui;
            _itemStore.Position = new Vector2(0, 48);
            _itemStore.OnLoad();
            this.Attach(_itemStore);
            items.ContainScene = _itemStore;

            AddTab(top);
            AddTab(items);
            SetselectTab(top);


            Sprite backGroundSprite = new Sprite();
            backGroundSprite.textureName = "item_store/block_04";
            backGroundSprite.ZIndex = Constants.background;
            backGroundSprite.OnLoad();
            backGroundSprite.Position = new Vector2(0, 48);
            this.Attach(backGroundSprite);
            SortChildren();
        }

        public int TotalPrice
        {
            get
            {
                int t = -99999;
                t = _spinningStore.TotalPrice + _itemStore.TotalPrice;
                return t;
            }
        }


        public override BaseScene Clone()
        {
            throw new NotImplementedException();
        }

        public void Save(Unitity.Storage.SaveData state)
        {
            _itemStore.Save(state);
            _spinningStore.Save(state);
        }

        public void Load(Unitity.Storage.SaveData state)
        {
            _itemStore.Load(state);
            _spinningStore.Load(state);
        }
    }
}
